package com.feihong.txgw.tx_model;

import android.text.TextUtils;

import com.feihong.txgw.http.HttpTools;
import com.feihong.txgw.inter.contract.adr.IDeliveryAdrEditContract;
import com.feihong.txgw.model.base_bean.BaseResponse;
import com.feihong.txgw.model.bean.deliveryAdr.DeliveryAdrEntity;
import com.feihong.txgw.utils.helper.RxHelper;
import com.feihong.txgw.utils.manage.RetrofitManager;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName EditDeliveryAdrMainModel
 * @package com.feihong.txgw.tx_model
 * @data 2018/5/7 19:46
 * @Describe
 * @Change
 */
public class EditDeliveryAdrMainModel implements IDeliveryAdrEditContract.IDeliveryAdrEditMainModel {
    @Override
    public Observable<BaseResponse> editAdr(DeliveryAdrEntity deliveryAdrEntity, String adrInfo) {
        Map<String,String> mParams = new HashMap<>();
        mParams.put("addr_id", TextUtils.isEmpty(deliveryAdrEntity.getAddr_id()) ? "" : deliveryAdrEntity.getAddr_id());
        mParams.put("name",deliveryAdrEntity.getConsignee());
        mParams.put("citycode",deliveryAdrEntity.getCitycode());
        mParams.put("address",deliveryAdrEntity.getAddress());
        mParams.put("adr_mobile",deliveryAdrEntity.getMobile());
        mParams.put("gender",deliveryAdrEntity.getGender());
        mParams.put("is_default",deliveryAdrEntity.getIs_default());
        mParams.put("location_info",adrInfo);
      return RetrofitManager.getInstance().editUserDeliveryAdr(HttpTools.ADR_EDIT_UPDATE,mParams).compose(RxHelper.<BaseResponse>rxSchedulerHelper());
    }

    public static EditDeliveryAdrMainModel create(){
        return new EditDeliveryAdrMainModel();
    }
}
